<%-- 
    Document   : display_profile
    Created on : 31 May, 2012, 4:36:32 PM
    Author     : bharat
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page  import="java.sql.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>ONLINE COLLEGE MAGAZINE</title>
    </head>
    <body>
        <%
            String username = (String) session.getAttribute("usr");

            Connection con = null;
            PreparedStatement pstmt = null;
            ResultSet rs = null;

            try {
                Class.forName("oracle.jdbc.driver.OracleDriver");
                con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

                pstmt = con.prepareStatement("select *from registered_users_db where usr_name=?");
                pstmt.setString(1, username);
                rs = pstmt.executeQuery();
                if (rs.next()) {
        %>

        <table border="0" cellpadding="5" align="center">
            <tr>
                <td colspan="3"> <a href=".out">Log out</a><br>
                    <a href=".cre_po">Create a new post</a>
                </td>
            </tr>

            <tr>
                <td> ID </td>
                <td> : </td>
                <td> <%=rs.getString(1)%> </td>
            </tr>
            <tr>
                <td> First Name </td>
                <td> : </td>
                <td> <%=rs.getString(2)%> </td>
            </tr>
            <tr>
                <td> Last Name </td>
                <td> : </td>
                <td> <%=rs.getString(3)%> </td>
            </tr>
            <tr>
                <td> Email </td>
                <td> : </td>
                <td> <%=rs.getString(4)%> </td>
            </tr>
            <tr>
                <td> Course </td>
                <td> : </td>
                <td> <%=rs.getString(7)%> </td>
            </tr>
            <tr>
                <td> Course Year </td>
                <td> : </td>
                <td> <%=rs.getString(8)%> </td>
            </tr>
        </table>

        <%                }
            } catch (Exception e) {
                response.sendError(555, e.getMessage());
                e.printStackTrace();
            } finally {
                if (rs != null) {
                    try {
                        rs.close();
                    } catch (Exception e) {
                        response.sendError(555, e.getMessage());
                    }
                }
                if (pstmt != null) {
                    try {
                        pstmt.close();
                    } catch (Exception e) {
                        response.sendError(555, e.getMessage());
                    }
                }
                if (con != null) {
                    try {
                        con.close();
                    } catch (Exception e) {
                        response.sendError(555, e.getMessage());
                    }
                }
            }
        %>

    </body>
</html>
